﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

namespace IKEA.FileExchange.Web
{
    public static class UrlHelper
    {
        public const int ApplicationAlternateUrlIndex = 1;

        public static string GetApplicationExternalUrl(SPSite spSite)
        {
            return (spSite.WebApplication.AlternateUrls[ApplicationAlternateUrlIndex].Uri.ToString());
        }

        public static string GetApplicationExternalUrl()
        {
            SPSite spSite = SPContext.Current.Site;

            return (spSite.WebApplication.AlternateUrls[ApplicationAlternateUrlIndex].Uri.ToString());
        }


        public static string GeneratePackageManagementUrl(string packageUniqueId)
        {
            string url = GetApplicationExternalUrl();

            return string.Format("{1}FilePackageManagement.aspx?p={0}", packageUniqueId,url);
        }

        public static string GenerateDownloadTicketPageUrl(string downloadTicketId)
        {
            string url = GetApplicationExternalUrl();

            return string.Format("{1}DownloadTicket.aspx?dt={0}", downloadTicketId, url);
        }


    }
}
